package Day07_21;

import Day07_14.Animal;

public class HomeWork01 {
    public static void main(String[] args) {
        Animal1 a3 = new Animal1();
        Animal1 a1 = new Cat();
        Animal1 a2 = new Brid();
        Animal1[] a = {a1,a2,a3};
        //Animal[] a = {new Brid(),new Cat()};
        for(int i=0;i<a.length;i++){
            if(a[i] instanceof Cat){
                ((Cat) a[i]).catchMouse();
            }
            else if( a[i] instanceof Brid){
                ((Brid) a[i]).sing();
            }
            else a[i].move();
        }

    }
}
class Animal1{
        public void move(){
            System.out.println("动物在移动....................");
        }
}
class Cat extends Animal1{
    public void move(){
        System.out.println("猫在地上轻轻地走..........");
    }
    public void catchMouse(){
        System.out.println("猫在抓老鼠.............");
    }

}
class Brid extends Animal1{
    public void move(){
        System.out.println("鸟儿在蓝天上飞翔...........");
    }
    public  void sing(){
        System.out.println("鸟儿在树上歌唱............");
    }
}
